<extend name="Base/common"/>
<block name="body">
    <div class="carbox width1000">
        <div class="top_tit">
            <a href="{:U('Index/index')}">首页</a> >> 投诉建议
        </div>
        <div class="complain">
            <div class="cdvice_list">
                <span class="cdvice_tag">投诉建议</span>
               <!--   <a href="javascript:void(0);" data-href="tab2">问题解答</a>-->
            </div>
            <form action="{:U('save')}" methos="post" class="forms_all" id="frm_propose">
            <div class="tab_content" style="min-height:400px">
            
                <div id="tab1">
                    
                        <div class="comp_list clearfix">
                            <div class="span2 f_l t_r">
                                问题描述：
                            </div>
                            <div class="span8 f_l">
                                <input type="text" name="title" />
                                <span class="help_msg"></span>
                            </div>
                        </div>
                        <div class="comp_list clearfix">
                            <div class="span2 f_l t_r">
                                问题详情：
                            </div>
                            <div class="span8 f_l">
                                <textarea name="question"></textarea>
                                <span class="help_msg"></span>
                            </div>
                        </div>
                        <if condition="is_login()">
                        <else />                        
                        <div class="comp_list clearfix">
                            <div class="span2 f_l t_r">
                                手机号码：
                            </div>
                            <div class="span8 f_l">
                                <input type="text" name="mobile" class="small_input"/>
                                <span class="help_msg"></span>
                            </div>
                        </div>
                        <div class="comp_list clearfix">
                            <div class="span2 f_l t_r">
                                验证码：
                            </div>
                            <div class="span8 f_l">
                                <input type="text" name="verify" class="small_input2"/>
                                <input type="button" class="small_code btn_hover" id="get_verify" value="获取验证码">
                                <span class="help_msg"></span>
                            </div>
                        </div>
                        </if>
                        
                   
                </div>
                </div>
		             <input type="submit" class="btn_hover comp_submit" value="提交" />
		         </form>
                
                 <div id="tab2">
                    <div class="comp_question">
                    <table width="100%" border="0">
                    <volist name="_list" id="vo">
                        <tr>
                        <td width="60">提问：</td>
                        <td>{$vo.title}</td>
                        <td align="right">{$vo.posttime}</td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td colspan="2">{$vo.question}</td>
                        </tr>
                        <tr>
                            <td>回答：</td>
                        <if condition="empty($vo['answer'])">
                        <td colspan="2">处理中...</td>
                        <else />
                        <td colspan="2">{$vo.answer}</td>
                        </if>
                        </tr>
                        <tr><td colspan="3">&nbsp;</td></tr>
                    </volist>
                    </table>
                    </div>
                    {$_page}
                </div>
            
        </div>
    </div>
</block>
<block name="script">
<script type="text/javascript">
var wait_time_p = 60; //60秒内

function wait_next_p(){
    if(wait_time_p<=0){
        $('#get_verify').attr("disabled", false).val('获取验证码');
        wait_time_p = 60;
    }else{
        wait_time_p --;
        $('#get_verify').attr("disabled", true).val('还有' + wait_time_p + '秒');
        setTimeout('wait_next_p()',1000);
    }
}

$().ready(function() {        
        $('#get_verify').click(function(){
            var form = $(this)[0].form,
                url = "{:U('User/getVerifyMsg')}";
            $.post(url,$(form).serialize(),function(data){
                if(data.status){
                    wait_next_p();
                } else {
                    alert(data.info);
                }
            },"json");
        })
        var validator = $("#frm_propose").validate({
                    rules:{
                        title:{
                            required:true,
                        },
                        question:{
                            required:true
                        }
                    },
                    messages:{
                        title:{
                            required:'请填写标题'
                        },
                        question:{
                            required:'请填写问题内容'
                        }
                    },
                    submitHandler:function(form){
                        var self = $(form);
                        $.post(self.attr("action"), self.serialize(), function(data){
                            if(data.status){
                                alert('投诉建议已经递交！');
                            } else {
                                alert(data.info);
                            }
                        }, "json");
                    }    
            });
});
</script>
</block>
